import {createRouter, createWebHashHistory, createWebHistory} from 'vue-router'
// import HomeView from '@/views/HomeView.vue'
// import SearchView from '@/views/SearchView.vue'
// import NotFoundView from '@/components/NotFoundView.vue'
// 创建路由实例
const router = createRouter({
  history: createWebHistory(), // hash 路由模式，地址栏有 #/ 标识
  routes: [// 路由配置表
    {path:'/find', component: () => import('@/views/FindView.vue')},
    {path:'/my', component: () => import('@/views/MyView.vue')},
    {path:'/friend', component: () => import('@/views/FriendView.vue')},
    {path: '/home', component: () => import('@/views/HomeView.vue')},
    // {path: '/search', component: SearchView}
    //redirect重定向，避免首页白屏
    {path: '/', redirect: '/home'},
    // {path: '/search/:keyword?', component: SearchView},
    { name: 'SearchView', path: '/search/:keyword?', component: ()=>import('@/views/SearchView.vue') },
    //404页面 路径不存在时，避免白屏
    // {path: '/:pathMatch(.*)*', component: NotFoundView} 此写法在页面最初加载时就会加载组件，浪费性能
    {path: '/:pathMatch(.*)*', component: ()=>import('@/components/NotFoundView.vue')}

  ],  // 路由配置表
})

// 导出了路由实例
export default router